import {ElNotification} from "element-plus";

const Method:any = {
    install(app:any) {
        // 封装提示失败的弹出框
        app.config.globalProperties.notifyError = function (msg:string,location:string):void {
            location = location? location: "top-left"
            // @ts-ignore
            ElNotification({
                title: '错误',
                message: msg,
                type: 'error',
                showClose: false,
                duration:1000,
                position: location
            })
        }
        // 封装警告提示框
        app.config.globalProperties.notifyWarning = function(msg:string,location:string):void {
            location = location? location: "top-left"
            // @ts-ignore
            ElNotification({
                title: '警告',
                message: msg,
                type: "warning",
                showClose: false,
                position: location,
                duration: 1000,
                offset: 100
            })
        }
        // 封装成功提示框
        app.config.globalProperties.notifySuccess = function(msg:string,location?:string,offset?:number) {
            location = location? location: "top-right"
            offset = offset? offset: 0
            // @ts-ignore
            ElNotification({
                title: '成功',
                message: msg,
                type: 'success',
                showClose: false,
                position: location,
                duration: 750,
                offset
            });
        }
    }
}
export default Method